# # 类的定义
# class Car:
#     wheels = 4
#     def drive(self):
#         print('开车方式')
#     def stop(self):
#         print('停车方式')
# # 对象的创建
# my_car = Car()
# print(my_car.wheels)
# my_car.drive()
# my_car.stop()

# # 访问限制
# class PersonInfo:
#     __weight = 55
#     def __info(self):
#         print(f'我的体重是{self.__weight}kg')
#     def get_weight(self):
#         print(f'我的体重是{self.__weight}kg')
#         self.__info

# 构造方法
# class Person:
#     def __init__(self,name,sex):
#         self.name = name
#         self.sex = sex
#         def introduce(self):
#             print(f'姓名:{self.name})
#             print(f'性别:{self.name})
# person_one = Person('小李', '女')
# person_one.introduce()
# person_two = Person('小张', '男')
#  person_two.introduce()


# # 类方法
# # 一.定义类方法
# class Test:
#     @classmethod
#     def use_classmet(cls):
#         print("我是类方法")
# # 二.调用类方法
#     test = Test()
#     test.use_classmet()
#     Test.use_classmet()

# # 三.修改类属性
# class Apple:
#     count = 0
#     @classmethod
#     def add_two(cls):
#         cls.count = 2
#     print(Apple.count)
#     Apple.add_two()
#     print(Apple.count)

# # 静态方法
# class Example:
#     num = 10
#     @staticmethod
#     def static_method():
#         print(f"类属性的值为：{Example.num}")
#         print("---静态方法")
#         example = Example()
#         example.static_method()
#         Example.static_method()

# # 单继承
# class Amphibian:
#     name = "两栖动物"
#     def features(self):
#         print("幼体用鳃呼吸")
#         print("成年用肺兼皮肤呼吸")
# class Frog(Amphibian):
#     def attr(self):
#         print("我会呱呱叫")
#     from = Frog()
#     print(frog.name)
#     frog.features()
#     frog.attr()

# # 多继承
# class English:
#     def receive_eng_know(self):
#         print('具备英语知识。')
# lass Math:
#     def receive_math_know(self):
#         print('具备数学知识。')
# class Student(English,Math):
#     def study(self):
#         print('学生的任务是学习。')
#     stu = Student()
#     stu.receive_eng_know()
#     stu.receive_math_know()
#     stu.study()

# # 方法的重写
# class Felines:
#     def speciality(self):
#         print("猫科动物善于奔跑")
# class Cat(Felines):
#     name = "猫"
#     def speciality(self):
#         print(f'{self.name}爱吃鱼')
#         print(f'{self.name}会爬树')
# cat = Cat()
# cat.speciality()

# # super()函数
# class Cat(Felines):
#     name = '猫'
#     def speciality(self):
#         print(f'{self.name}爱吃鱼')
#         print(f'{self.name}会爬树')
#         print('-'*20)
#         super().speciality()
# cat = Cat()
# cat.speciality()

# 多态
class Animal(object):
    def move(self):
        pass
class Rabbit(Animal):
    def move(self):
        print("兔子蹦蹦跳跳")
class Snail(Animal):
    def move(self):
        print("蜗牛缓慢爬行")
def test(obj):
    obj.move()
rabbit = Rabbit()
test(rabbit)
snail = Snail()
test(snail)



